package cn.butcher.service.impl;

import cn.butcher.mapper.StudentMapper;
import cn.butcher.service.StudentService;
import cn.butcher.utils.SendMsg;
import cn.butcher.vo.LeaveForm;
import cn.butcher.vo.StudentLeaveMsg;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    StudentMapper mapper;

    @Override
    public String getNameById(int id) {
        return mapper.getNameById(id);
    }

    @Override
    public String getTeacherNameById(int cId) {
        return mapper.getTeacherNameById(cId);
    }

    @Override
    public int insertLeave(LeaveForm leaveForm) {
        return mapper.insertLeave(leaveForm);
    }

    @Override
    public List<StudentLeaveMsg> getStudentLeaveMsg(char status, int id) {
        return mapper.getStudentLeaveMsg(status, id);
    }


    @Override
    public int changeLeaveStatus(char status, int id) {
        return mapper.changeLeaveStatus(status, id);
    }

    @Override
    public int delayLeaveDate(String reason, String date, int id) {


        return mapper.delayLeaveDate(reason, date, id);
    }

    @Override
    public void sendUrge(int leId) throws TencentCloudSDKException {
        Map<String, String> map = mapper.getTeacherPhoneByLeId(leId);
        String nums[] = {"+86" + map.get("phone")};
        String temps[] = {map.get("teacher"), map.get("student")};
        SendMsg.send("1054057", nums, temps);
        // ok我们试试，没有成功
    }
}
